package com.servlet;

import com.dao.imp.FindAllType;
import com.entity.ChildType;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;

import com.util.DBConn;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import java.io.IOException;
import java.util.List;

/**
 * @author Mathison
 * @Title: ${NAME}
 * @Package: ${PACKAGE_NAME}
 * @Description: TODO
 * @date 2021/11/21 16:54
 **/

@WebServlet(name = "GetChildTypeServlet", value = "/GetChildTypeServlet")
public class GetChildTypeServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");
        FindAllType findAllType = new FindAllType();
        String id = request.getParameter("parentId");
        List<ChildType> childTypeList = findAllType.getChildType(id);

        JSONArray json = JSONArray.fromObject(childTypeList);
        response.getWriter().print(json);
    }
}
